package com.example.backend.mapper;

import com.example.backend.entity.Sign;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Component
@Mapper

public interface SignMapper {
    //增加签到
    @Insert("insert into Sign (userId,lastDate) values (#{userId},#{lastDate})")
    int insertSign(@Param("userId") int userId, @Param("lastDate") String lastDate);

    //更新签到
    @Update("update Sign set daysCount = daysCount + 1,lastDate = #{lastDate} where userid = #{userid}")
    int updateSign(@Param("userid") int userid,@Param("lastDate") String lastDate);

    //查看签到
    @Select("select * from Sign where userId = #{userId}")
    List<Sign> ifSign(@Param("userId") int userId);
}
